package com.qidian.mespro.controller;

import com.github.pagehelper.PageInfo;
import com.qidian.mespro.service.ProcessService;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.Process;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ Description:
 * @ Author: DuYaTao
 * @ Date: 2025/9/17 - 16:56
 */
@RestController
@RequestMapping("/process")
public class ProcessController {

    @Autowired
    private ProcessService processService;

    @GetMapping("/page")
    public Result<PageInfo<Process>> list(Process process, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int size) {
        return processService.selectProcessList(process, page, size);
    }

    @PostMapping("/add")
    public Result<Process> add(@RequestBody Process process) {
        return processService.addProcesser(process);
    }

    @GetMapping("/code/{code}")
    public Result<Process> selectByCode(@PathVariable String code) {
        return processService.selectProcesserByCode(code);
    }

    @PutMapping("/update")
    public Result<Process> update(@RequestBody Process process) {
        return processService.updateProcesser(process);
    }

    @DeleteMapping("/delete/{id}")
    public Result<Process> deleteById(@PathVariable Long id) {
        return processService.deleteById(id);
    }

    @DeleteMapping("/batchDelete")
    public Result<Process> batchDeleteByIds(Long[] id) {
        return processService.batchDeleteByIds(id);
    }
}

